package operate;

import book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User: Administrator
 * Data: 2023 - 05 - 10
 * Time: 20:54
 */
public class ReturnOperate implements IOperation{
    @Override
    public void work(BookList bookList) {
        System.out.println("请输入你要归还的图书的名字");
        Scanner scanner = new Scanner(System.in);
        String bookName = scanner.nextLine();
        int currentNums = bookList.getBooknumbers();
        for (int i = 0; i < currentNums; i++) {
            if(bookList.getBook(i).getName().equals(bookName)) {
                if((bookList.getBook(i).getBorrow()) == false) {
                    System.out.println("图书存在，不用归还");
                }else {
                    bookList.getBook(i).setBorrow(false);
                }
                return;
            }
        }
        System.out.println("该图书不属于图书馆，不用归还");
    }
}
